<?php

namespace app\admin\controller;

use think\Controller;
use think\Db;
use think\Request;

class Cuser extends Controller
{

    public function index()
    {
        //todo:从数据库里查询到用户数据
       $data = Db('user')->select();
       return view('cuser/list',[
           'data'=>$data,
           'title'=>'用户管理',
       ]);
    }


    public function delete(Request $request)
    {
       $data =  $request->param();
       //todo:执行删除
        $res = Db('user')->where('id',$data['id'])->delete();
        if($res){
            $info['status'] = true;
            $info['info'] = '删除成功';
        }else{
            $info['status'] = false;
            $info['info'] = '删除失败';
        }

        return json($info);
    }
}
